#include "unp.h"

void dg_cli(FILE *fp, int fd, struct sockaddr *servaddr, socklen_t servlen)
{
    ssize_t n;
    char sendline[MAXLINE], recvline[MAXLINE];

    Connect(fd, servaddr, servlen);

    printf("using connect ..\n");

    while (Fgets(sendline, sizeof(sendline), fp) != NULL) {
        Send(fd, sendline, strlen(sendline), 0);
        n = Recv(fd, recvline, sizeof(recvline), 0);
        recvline[n] = '\0';
        Fputs(recvline, stdout);
    }
}

